package validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class validatorName implements Validator {

    private Pattern pattern;
    private Matcher matcher;
    private static final String CARAC_PATTERN = "";

    public validatorName() {
        pattern = Pattern.compile(CARAC_PATTERN);
    }

    @Override
    public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
        matcher = pattern.matcher(value.toString().trim());
        if (matcher.matches()) {
            FacesMessage msg =
                    new FacesMessage("Caracter Invalid", "Caracter Invalid");
            msg.setSeverity(FacesMessage.SEVERITY_ERROR);
            throw new ValidatorException(msg);
        }
    }
}
